<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>测试接口</title>
    <!-- 引入线上的jq文件 -->
    <script src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
   <button id="btnGET">GET请求接口</button> 
   <button id="btnPOST">POST请求接口</button>
   <button id="btnDelete">Delete请求接口</button> 

   <script>
       $(function() {
        
        // 测试GET接口
        $("#btnGET").on('click', () => {

            $.ajax({
                method: 'GET',
                url: 'http://127.0.0.1/api/get',
                data: { name:'zs', age: 20},
                success: function(res) {
                    console.log(res)
                }
            })
        })

        // 测试post接口
        $("#btnPOST").on('click', () => {
            $.ajax({
                method: 'POST',
                url: 'http://127.0.0.1/api/post',
                data:{ bookname:'水浒传', author: '施耐庵'},
                success: (res) => {
                    console.log(res)
                }

            })
        })


        // 测试delete 接口
        $("#btnDelete").on('click', () => {
            $.ajax({
                method:'DELETE',
                url: 'http://127.0.0.1/api/delete',
                success: (res) => {
                    console.log(res)
                }
            })
        })


       })

    
   </script>

</body>
</html>